#!/usr/bin/env python
# -*- coding: utf-8 -*-

def quick_sort(array):
    if len(array) <= 1:
        # 基线条件：为空或者只有一个元素
        return array
    else:
        # 递归条件
        pivot = array[0]
        less = [i for i in array[1:] if i <= pivot]
        greater = [i for i in array[1:] if i > pivot]
        
        return quick_sort(less) + [pivot] + quick_sort(greater)

if __name__=='__main__':
    my_list = [5, 3, 6, 2, 10]
    print quick_sort(my_list)
    
